package com.ohs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ohs.mapper.before.IndexMapper;
import com.ohs.pojo.Product;
import com.ohs.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class IndexServiceImpl implements IndexService {
    @Autowired(required = false)
    IndexMapper indexMapper;
    @Override
    public String indexData(HttpSession session, Model model) {
        //获取类型为摆件花艺的商品
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("proType","摆件花艺");
        List<Product> proBaiJian = indexMapper.selectList(queryWrapper);

        //获取类型为壁挂的商品
        QueryWrapper<Product> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("proType","壁挂");
        List<Product> proBiGua = indexMapper.selectList(queryWrapper1);

        //绑定数据
        model.addAttribute("proBiGua",proBiGua);
        model.addAttribute("proBaiJian",proBaiJian);
        return "before/index";
    }
}
